package com.cabrida.livestar.star;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.cabrida.livestar.R;
import com.cabrida.livestar.model.FansStarRedGiftData;
import com.cabrida.livestar.util.MyUtils;

/**
 * 粉丝端，明星送出的红包adapter
 * 
 * @author why
 * 
 */
public class StarRedPacketLvAdapter extends BaseAdapter {

	private LayoutInflater mInflater;
	private ArrayList<FansStarRedGiftData> data_list = new ArrayList<FansStarRedGiftData>();

	public StarRedPacketLvAdapter(Context context) {
		this.mInflater = LayoutInflater.from(context);
	}

	public void setData(ArrayList<FansStarRedGiftData> data) {
		data_list = data;
	}

	@Override
	public int getCount() {
		return data_list.size();
	}

	@Override
	public Object getItem(int arg0) {
		return data_list.get(arg0);
	}

	@Override
	public long getItemId(int arg0) {
		return arg0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {

		ViewHolder holder = null;
		if (convertView == null) {

			holder = new ViewHolder();

			convertView = mInflater.inflate(
					R.layout.adapter_star_red_packet_lv_item, null);
			holder.tv_time = (TextView) convertView.findViewById(R.id.tv_time);
			holder.tv_number = (TextView) convertView.findViewById(R.id.tv_number);
			holder.iv_header = (ImageView) convertView.findViewById(R.id.iv_header);
			convertView.setTag(holder);

		} else {
			holder = (ViewHolder) convertView.getTag();

		}
		
		MyUtils.loadImg(data_list.get(position).getL_image(), holder.iv_header);
		holder.tv_time.setText(data_list.get(position).getI_createtime());
		holder.tv_number.setText(data_list.get(position).getMoney());

		return convertView;
	}

	class ViewHolder {
		private TextView tv_time;
		private TextView tv_number;
		private ImageView iv_header;
	}

}
